package com.egao.common.module.system.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Date;
import java.util.List;

/**
 * 用户
 *
 * @author system
 */
@ApiModel(description = "用户")
@TableName("sys_user")
public class User implements UserDetails {

    @ApiModelProperty("用户id")
    @TableId(value = "user_id", type = IdType.AUTO)
    private Integer userId;

    @ApiModelProperty("用户类型 1教师 2学生 3单位")
    private String userType;

    @ApiModelProperty("账号")
    private String username;

    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("学院编码")
    private String collegeCode;

    @ApiModelProperty("学生管理范围 0全部 1管理所属(学生表中有所属辅导员列)")
    private String studentScope;

    @ApiModelProperty("学生管理范围 0全部 1本科 2研究生")
    private String degreeScope;

    @ApiModelProperty("班级号码")
    private String bjhm;

    @ApiModelProperty("学院名称")
    @TableField(exist = false)
    private String collegeName;

    @ApiModelProperty("姓名")
    private String name;

    @ApiModelProperty("手机号")
    private String mobile;

    @ApiModelProperty("邮箱")
    private String email;

    @ApiModelProperty("头像")
    private String avatar;

    @ApiModelProperty("用户状态 0正常 1冻结")
    private Integer state;

    @ApiModelProperty("通过cas入库 0否 1是")
    private Integer cas;

    @ApiModelProperty(value = "归属单位编号", notes = "用于产教融合附属单位账户")
    private Integer companyId;

    @ApiModelProperty("是否删除 0否 1是")
    @TableLogic
    private Integer deleted;

    @ApiModelProperty("登录次数")
    private Integer loginCount;

    @ApiModelProperty("注册时间")
    private Date createTime;

    @ApiModelProperty("编辑时间")
    private Date updateTime;

    @ApiModelProperty("单位问卷 0已做 1未做")
    private String companyQuestionnaire;

    @ApiModelProperty("角色id")
    @TableField(exist = false)
    private List<Integer> roleIds;

    @ApiModelProperty("角色列表")
    @TableField(exist = false)
    private List<Role> roles;

    @ApiModelProperty("权限列表")
    @TableField(exist = false)
    private List<Menu> authorities;

    @ApiModelProperty("查看推送明细次数")
    @TableField(exist = false)
    private Integer pushViewCount;

    public String getCompanyQuestionnaire() {
        return companyQuestionnaire;
    }

    public void setCompanyQuestionnaire(String companyQuestionnaire) {
        this.companyQuestionnaire = companyQuestionnaire;
    }

    public Integer getPushViewCount() {
        return pushViewCount;
    }

    public void setPushViewCount(Integer pushViewCount) {
        this.pushViewCount = pushViewCount;
    }

    public String getBjhm() {
        return bjhm;
    }

    public void setBjhm(String bjhm) {
        this.bjhm = bjhm;
    }

    public Integer getLoginCount() {
        return loginCount;
    }

    public void setLoginCount(Integer loginCount) {
        this.loginCount = loginCount;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getStudentScope() {
        return studentScope;
    }

    public void setStudentScope(String studentScope) {
        this.studentScope = studentScope;
    }

    public String getCollegeCode() {
        return collegeCode;
    }

    public void setCollegeCode(String collegeCode) {
        this.collegeCode = collegeCode;
    }

    public String getCollegeName() {
        return collegeName;
    }

    public void setCollegeName(String collegeName) {
        this.collegeName = collegeName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getDegreeScope() {
        return degreeScope;
    }

    public void setDegreeScope(String degreeScope) {
        this.degreeScope = degreeScope;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public Integer getDeleted() {
        return deleted;
    }

    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }

    public List<Menu> getAuthorities() {
        return authorities;
    }

    public void setAuthorities(List<Menu> authorities) {
        this.authorities = authorities;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    public List<Integer> getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(List<Integer> roleIds) {
        this.roleIds = roleIds;
    }

    public Integer getCas() {
        return cas;
    }

    public void setCas(Integer cas) {
        this.cas = cas;
    }

    public Integer getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return state == 0;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public String toString() {
        return "User{" +
                ", userId=" + userId +
                ", username=" + username +
                ", password=" + password +
                ", studentScope=" + studentScope +
                ", collegeCode=" + collegeCode +
                ", name=" + name +
                ", mobile=" + mobile +
                ", email=" + email +
                ", avatar=" + avatar +
                ", state=" + state +
                ", deleted=" + deleted +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                "}";
    }

}
